﻿#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <syslog.h>
#include <signal.h>
#include "xmlsock.h"
#include "Debug.h"
#include "loadflags.h"
#include "semproc_lock.h"

int main(int argc , char **argv)
{
	if(argc < 3 )
	{
		Safe_Printf(" Invalid Input argc<3 \n");
		//exit(0);
	}

//    int ret = 0;
	char szTmp[32] = {0};
	xml_init(9999);


    int nTmp = 0;
    while(1){
     sleep(5);
     xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display1", &nTmp, 0); Safe_Printf("display 1 n= %d\n" , nTmp);
     xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display2", &nTmp, 0); Safe_Printf("display 2 n= %d\n" , nTmp);
    }

    while(1){
    Safe_Printf("===== set ==============\n\n\n");
    xml_sets(CONF_SIPSETTING, "sipsetting/M_SIP/display1", "3004", XML_SAVE_DELAY);
    xml_sets(CONF_SIPSETTING, "sipsetting/M_SIP/display2", "5004", XML_SAVE_DELAY);
    sleep(5);
    }

    Safe_Printf("===== re get ==============\n\n\n");
    xml_gets(CONF_SIPSETTING, "sipsetting/M_SIP/display1", szTmp, sizearray(szTmp), 0);	Safe_Printf("display 1 s= %s\n" , szTmp);
    xml_gets(CONF_SIPSETTING, "sipsetting/M_SIP/display2", szTmp, sizearray(szTmp), 0);	Safe_Printf("display 2 s= %s\n" , szTmp);
    Safe_Printf("===================\n");

    //  unsigned 
    unsigned int uNum = 123;
    xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display1", (int *)&uNum, 0); Safe_Printf("display 1 u = %u\n" , uNum);
    xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display2", (int *)&uNum, 0); Safe_Printf("display 2 u = %u\n" , uNum);
    unsigned short usNum = 123;
    xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display1", (int *)&usNum, 0); Safe_Printf("display 1 us = %u\n" , usNum);
    xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display2", (int *)&usNum, 0); Safe_Printf("display 2 us = %u\n" , usNum);

    // array 
    int aa_state[2];
    xml_getn(CONF_SIPSETTING, "sipsetting/M_SIP/display1", (int *)&aa_state[0], 0);  Safe_Printf("display 1 arr = %u\n" , aa_state[0]);

    // networksetting
    xml_gets(CONF_NETWORKSET, "networksetting/M_WAN/password", szTmp, sizearray(szTmp), 0);  Safe_Printf("password = %s\n" , szTmp);

    while(1) sleep(1000);

    return 0;
}

